<template>
    <el-dialog title="输入密码" :visible.sync="showPwdDialog" :modal="true" :append-to-body="true"
               :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" center>
        <el-form onsubmit="return false;">
            <el-form-item>
                <el-input v-model="inputPwd" show-password @keyup.enter.native="checkPassword"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="checkPassword">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import {mapGetters} from 'vuex'

    export default {
        name: "Password",
        data() {
            return {
                showPwdDialog: true,
                inputPwd: '',
            }
        },
        computed: {
            ...mapGetters(['getPassword']),
        },
        methods: {
            checkPassword() {
                let password = this.getPassword;
                if (this.inputPwd === password) {
                    this.$utils.AppMessage.success('登录成功');
                    this.showPwdDialog = false;
                } else {
                    this.$utils.AppMessage.error('密码错误！');
                }
            }
        }
    }
</script>

<style scoped>

</style>